﻿using UnityEngine;
using System.Collections;

public class CameraMovementBounds : MonoBehaviour {
	
	public float minX;
	public float maxX;
	
	public float minY;
	public float maxY;
	
	public float minZ;
	public float maxZ;
	
	public float cameraSpeed;
	
	private Vector3 minBounds;
	private Vector3 maxBounds;
	
	private float moveDirectionVertical;
	private float moveDirectionHorizontal;
	
	private GameObject camera;
	
	// Use this for initialization
	void Start () 
	{
		camera = GameObject.Find ("MainCamera");
		
		minBounds = new Vector3(minX, minY, minZ);
		maxBounds = new Vector3(maxX, maxY, maxZ);
	}
	
	// Update is called once per frame
	void Update () 
	{
		moveDirectionVertical=Input.GetAxis ("Vertical") * cameraSpeed;
		moveDirectionHorizontal=Input.GetAxis ("Horizontal") * cameraSpeed;
		
		transform.position = new Vector3(transform.position.x + moveDirectionHorizontal, transform.position.y + moveDirectionVertical, transform.position.z);
		
		transform.position = new Vector3(
			Mathf.Clamp(transform.position.x, minBounds.x, maxBounds.x),
			Mathf.Clamp(transform.position.y, minBounds.y, maxBounds.y),
			transform.position.z);
			
	}
}
